package com.h2psoft.truyen.tranh.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.h2psoft.truyen.tranh.R;
import com.h2psoft.truyen.tranh.activities.FragmentListComic;
import com.h2psoft.truyen.tranh.activities.FragmentNewComic;
import com.h2psoft.truyen.tranh.constants.Constants;

public class AdapterListFragment extends FragmentPagerAdapter {
	private Context context;

	public AdapterListFragment(FragmentManager fm, Context context) {
		super(fm);
		this.context = context;
	}

	@Override
	public int getCount() {
		return Constants.PAGE_COUNT;
		// return 1;
	}

	@Override
	public CharSequence getPageTitle(int position) {
		String title = "";
		if (position == 0) {
			title = context.getResources().getString(R.string.list_comic);
		} else if (position == 1)
			title = context.getResources().getString(R.string.new_comic);
		return title;
	}

	@Override
	public Fragment getItem(int position) {
		switch (position) {
		case 0:
			return FragmentListComic.newInstance(context.getResources().getString(R.string.list_comic));
		case 1:
			return FragmentNewComic.newInstance(0);
		}
		return null;

	}
}